import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: a
 * Date: 2022-07-17
 * Time: 20:13
 */
public class JDBC_Select {
    public void Select(Connection connection) throws SQLException {
        String sql="select * from student";

        PreparedStatement statement= connection.prepareStatement(sql);

        ResultSet resultSet=statement.executeQuery();

        while(resultSet.next()){
            int id=resultSet.getInt("id");
            String name=resultSet.getString("name");
            System.out.println(id+" : "+name);
        }

        statement.close();
        connection.close();
    }
}
